package com.project.gjbus.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.project.gjbus.dto.ParamDto;
import com.project.gjbus.entity.Zhanji;
import com.project.gjbus.mapper.ZhanjiMapper;
import com.project.gjbus.service.ZhanjiService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ZhanjiServiceImpl implements ZhanjiService {

    @Resource
    private ZhanjiMapper zhanjiMapper;

    @Override
    @DS("master")
    public Integer getCount(ParamDto paramDto) {
        return zhanjiMapper.getCount(paramDto);
    }

    @Override
    @DS("master")
    public List<Zhanji> getList(ParamDto paramDto) {
        return zhanjiMapper.getList(paramDto);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    @DS("readbase")
    public void saveList(List<Zhanji> list) {
        for (Zhanji entity : list) {
            zhanjiMapper.insertSelective(entity);
        }
    }

    @Override
    @DS("readbase")
    public Integer getReadBaseCount(ParamDto paramDto) {
        return zhanjiMapper.getCountReadbase(paramDto);
    }
}
